How to change any div color when double click on any element?
Change any div color when double click on any element
201
29-Jul-2021
Aryan Kumar
14-Jun-2023Sure, here is the JavaScript code to change any div color when double click on any element:
Code snippet
This code will add a listener for the dblclick event to all div elements. When an element is double clicked, the code will get the current background color, change the background color to red, and then set a timeout to change the background color back to the original color after 500 milliseconds.
Here is an example of how the code can be used:
Code snippet
When you double click on any of the div elements, the background color will change to red. After 500 milliseconds, the background color will change back to the original color.